# -*- coding: utf-8 -*-
from openerp import models, fields, api

class gmq_bs_seat_room(models.Model):
    '''
    图书馆教室
    '''
    _name = 'gmq.bs.seat.room'
    _rec_name = 'name'
    _description = u'图书馆教室'

    name = fields.Char(u'教室')
    isactivity = fields.Boolean(u'是否开放',default = True)
    seat = fields.One2many('gmq.bs.seat','room',u'关联座位')
    dyfloor = fields.Many2one('gmq.bs.seat.floor',u'楼层')
    dylibrary = fields.Many2one('gmq.bs.seat.library',u'图书馆')
    seat_pic = fields.Binary(u'座位图片(图片大小：410x200)')

    # @api.onchange('isactivity')
    # def _onchange_seat(self):
    #     print(self.id)
    #     sql = \
    #         """
    #         select id from gmq_bs_seat where room = %s
    #         """ % self.id
    #     self._cr.execute(sql)
    #     res = self._cr.fetchall()
    #     if self.isactivity == False:
    #         for seat in res:
    #             sql = \
    #                 """
    #                 update gmq_bs_seat set seat_state = FALSE
    #             where id = %s
    #                 """ % seat
    #             self._cr.execute(sql)
    #     if self.isactivity == True:
    #         for seat in res:
    #             sql = \
    #                 """
    #                 update gmq_bs_seat set seat_state = TRUE
    #             where id = %s
    #                 """ % seat
    #             self._cr.execute(sql)